/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Pojo;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author jeferson
 */
@Entity
@Table(name = "TB_GRAVADORA", catalog = "musical", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TbGravadora.findAll", query = "SELECT t FROM TbGravadora t"),
    @NamedQuery(name = "TbGravadora.findByGraCodigo", query = "SELECT t FROM TbGravadora t WHERE t.graCodigo = :graCodigo"),
    @NamedQuery(name = "TbGravadora.findByGraDescricao", query = "SELECT t FROM TbGravadora t WHERE t.graDescricao = :graDescricao")})
public class TbGravadora implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "GRA_CODIGO")
    private Long graCodigo;
    @Column(name = "GRA_DESCRICAO")
    private String graDescricao;
    @OneToMany(mappedBy = "proCodgravadora")
    private List<TbProduto> tbProdutoList;

    public TbGravadora() {
    }

    public TbGravadora(Long graCodigo) {
        this.graCodigo = graCodigo;
    }

    public Long getGraCodigo() {
        return graCodigo;
    }

    public void setGraCodigo(Long graCodigo) {
        Long oldGraCodigo = this.graCodigo;
        this.graCodigo = graCodigo;
        changeSupport.firePropertyChange("graCodigo", oldGraCodigo, graCodigo);
    }

    public String getGraDescricao() {
        return graDescricao;
    }

    public void setGraDescricao(String graDescricao) {
        String oldGraDescricao = this.graDescricao;
        this.graDescricao = graDescricao;
        changeSupport.firePropertyChange("graDescricao", oldGraDescricao, graDescricao);
    }

    @XmlTransient
    public List<TbProduto> getTbProdutoList() {
        return tbProdutoList;
    }

    public void setTbProdutoList(List<TbProduto> tbProdutoList) {
        this.tbProdutoList = tbProdutoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (graCodigo != null ? graCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TbGravadora)) {
            return false;
        }
        TbGravadora other = (TbGravadora) object;
        if ((this.graCodigo == null && other.graCodigo != null) || (this.graCodigo != null && !this.graCodigo.equals(other.graCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return graDescricao;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
